# -*- coding: utf-8 -*-
# @Author: QX
# @File: day7_0072touchaction.py
from time import sleep

from  appium   import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from appium.webdriver.common.touch_action import TouchAction

dic = {
  "platformName": "Android",
  "appium:platformVersion": "9",
  "appium:appPackage": "com.android.settings",
  "appium:appActivity": ".Settings",
  "appium:deviceName": "emulator-5554",
  "appium:automationName": "UIAutomator2"
}
driver = webdriver.Remote('http://127.0.0.1:4723',dic)
sleep(1)
ele = driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,'new UiSelector().text("电池")')
print(ele.get_attribute('text'))
print(ele.get_attribute('resource-id'))
print(ele.location,ele.location['x'],ele.location['y'])
print(ele.size,ele.size['height'])
#生成对象
action =  TouchAction(driver)
action.tap(element=ele).perform()
#
#action.press(x=57,y=107).wait(ms=1000).release().perform()
ele = driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,'new UiSelector().text("应用正常运行中")')
action.long_press(el=ele, duration=1000).perform()
action.long_press(x=749,y=929,duration=1000).perform()
